package com.foreverwin.jzymes.common.service.impl;

import com.foreverwin.jzymes.common.mapper.DCGroupAdviceMapper;
import com.foreverwin.jzymes.common.service.IDCGroupAdviceService;
import com.foreverwin.jzymes.common.util.BOHandleUtil;
import com.foreverwin.jzymes.framework.util.I18nUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;

import java.util.List;
import java.util.Map;

@Service
public class DCGroupAdviceServiceImpl implements IDCGroupAdviceService {

    @Autowired
    DCGroupAdviceMapper dcGroupAdviceMapper;


    public Map<String,Object> findDCGroup( String site, String dcGroup ){
        Assert.hasText( site, I18nUtil.getI18nText( "common.siteNotBlank" ) );
        Assert.hasText( dcGroup, I18nUtil.getI18nText( "common.dcGroupNotBlank" ) );

        return dcGroupAdviceMapper.selectDCGroup( site, dcGroup );
    }

    public String findDCGroupBo( String site, String dcGroup ){
        Map<String,Object> dcGroupMap = findDCGroup( site, dcGroup );
        if( dcGroupMap != null ){
            return (String) dcGroupMap.get( "HANDLE" );
        }else{
            return null;
        }
    }


    public List<Map<String,Object>> findDCParameterList( String site, String dcGroup ){
        String dcGroupBo = findDCGroupBo( site, dcGroup );

        return dcGroupAdviceMapper.selectDCParameterList( dcGroupBo );
    }
}
